package shuimin.weixin;

import pond.common.S;
import shuimin.weixin.security.AccessToken;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Map;

/**
 * Created by sky on 16/5/20.
 */
public class WeixinMedia {

    public static Map<String, Object> tempUpload(InputStream is,String name,String type) throws IOException {
        String url = Constant.QY_API_URL_PREFIX + Constant.MEDIA_TEMP_UPLOAD + "access_token=" + AccessToken.getAccessToken() + "&type=" + type;
        return HTTP.postImage(url,name,is,"image");
    }

    public static File tempGet(String media_id) throws UnsupportedEncodingException {
        S._assert(media_id);
        String url = Constant.QY_API_URL_PREFIX + Constant.MEDIA_TEMP_GET + "access_token=" + AccessToken.getAccessToken() + "&media_id=" + media_id;
        return HTTP.getFile(url);
    }


}
